from django.db import models

# Create your models here.
class Student(models.Model):
    stu_name=models.CharField(max_length=50,unique=True,verbose_name='学生账号名')
    stu_email=models.EmailField(verbose_name='学生邮箱')
    stu_password=models.CharField(max_length=50,verbose_name='学生密码')
    def __str__(self):
        return self.stu_name
    class Meta:
        db_table='student'


class Comments(models.Model):
    title=models.CharField(max_length=50,verbose_name='标题')
    content=models.TextField(verbose_name='内容')
    create_time=models.DateTimeField(verbose_name='创建时间')
    student=models.ForeignKey(Student,on_delete=models.CASCADE,null=True,verbose_name='学生')

    def __str__(self):
        return self.title

    class Meta:
        db_table = 'comments'


# 创建新的
class Post(models.Model):
    title = models.CharField(max_length=50, verbose_name='标题')
    content = models.TextField(verbose_name='内容')
    create_time = models.DateTimeField(verbose_name='创建时间')
    student = models.ForeignKey(Student, on_delete=models.CASCADE, null=True, verbose_name='学生')
    def __str__(self):
        return self.title
    class Meta:
        db_table = 'post'